import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { TTotalLoadReward } from "../../../Message/Db/Tables/TTotalLoadReward";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
type int = number;
//class TotalLoadRewardConfig
    
    export  class TotalLoadRewardConfig
    {
        constructor()
        {
            
            this._dayArr = [];
            this._extraRewardMap = new Map<any, any> /* flash.utils.Dictionary */();
            this._rewardMap = new Map<any, any> /* flash.utils.Dictionary */();
            if (TotalLoadRewardConfig._instance != null) 
            {
                throw new Error("TotalLoadRewardConfig单例");
            }
            this.init();
            return;
        }

        public TotalLoadRewardConfig.get maxDay(): int
        {
            return this._maxDay;
        }

        /* internal  */init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_total_load_reward.json");
            this.write(loc1);
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TTotalLoadReward();
                loc1.day = loc2.day;
                loc1.extraReward = StringHelper.getString(loc2.extraReward);
                loc1.reward = StringHelper.getString(loc2.reward);
                loc1.value = arg1.value;
                this._extraRewardMap[loc1.day] = loc1.extraReward;
                this._rewardMap[loc1.day] = loc1.reward;
                this._dayArr.push(loc1.day);
                if (!(loc1.day > this._maxDay)) 
                {
                    continue;
                }
                this._maxDay = loc1.day;
            }
            return;
        }

        public getExtraReward(arg1: int): string
        {
            return this._extraRewardMap[arg1];
        }

        public getReward(arg1: int): string
        {
            return this._rewardMap[arg1];
        }

        public getNextRewardDay(arg1: int): int
        {
            var loc1=0;
            while (loc1 < this._dayArr.length) 
            {
                if (this._dayArr[loc1] > arg1) 
                {
                    return this._dayArr[loc1];
                }
                ++loc1;
            }
            return -1;
        }

        public getExtraRewardDay(arg1: int): int
        {
            if (this._extraRewardMap[arg1]) 
            {
                return arg1;
            }
            var loc1=0;
            while (loc1 < this._dayArr.length) 
            {
                if (this._dayArr[loc1] > arg1) 
                {
                    if (this._dayArr[loc1] == 2) 
                    {
                        return this._dayArr[loc1];
                    }
                    return this._dayArr[(loc1 - 1)];
                }
                ++loc1;
            }
            return 0;
        }

        public static get instance(): TotalLoadRewardConfig
        {
            if (TotalLoadRewardConfig._instance == null) 
            {
                TotalLoadRewardConfig._instance = new TotalLoadRewardConfig();
            }
            return TotalLoadRewardConfig._instance;
        }

        /* internal */ /* var */_dayArr: Array<any>;

        /* internal */ /* var */_extraRewardMap: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_rewardMap: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_maxDay: int;

        /* internal */ static /* var */_instance: TotalLoadRewardConfig;
    }
